package com.qianyu.project.mapper.provider.mfy;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qianyu.project.entity.DeviceRequirePlan;
import com.qianyu.project.entity.MaterialInfo;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.util.StringUtils;

import java.util.Map;

/**
 * @Author mfy
 * @desc
 */
public class DeviceRequirePlanProvider {

    public String Mylist(IPage<DeviceRequirePlan> page, Map<String, String> params){
        return new SQL(){
            {
                SELECT("*");
                FROM("device_require_plan drp,system_user su,project_info pi");
                WHERE("drp.fill_user=su.id and drp.p_id=pi.id");
                if(!StringUtils.isEmpty(params.get("plianName"))){
                    WHERE("drp.plian_name like '%"+params.get("plianName")+"%'");
                }
                if(!StringUtils.isEmpty(params.get("tbdate"))){
                    WHERE("drp.tbdate <= '"+params.get("tbdate")+"'");
                }
                if(!StringUtils.isEmpty(params.get("xydate"))){
                    WHERE("drp.xydate >= '"+params.get("xydate")+"'");
                }
                if(!StringUtils.isEmpty(params.get("approveStatus"))){
                    WHERE("drp.approve_status = '"+params.get("approveStatus")+"'");
                }
            }
        }.toString();
    }

    public String listNopage(Map<String, String> params){
        return new SQL(){
            {
                SELECT("*");
                FROM("device_require_plan drp,system_user su,project_info pi");
                WHERE("drp.fill_user=su.id and drp.p_id=pi.id");
                if(!StringUtils.isEmpty(params.get("plianName"))){
                    WHERE("drp.plian_name like '%"+params.get("plianName")+"%'");
                }
                if(!StringUtils.isEmpty(params.get("tbdate"))){
                    WHERE("drp.tbdate <= '"+params.get("tbdate")+"'");
                }
                if(!StringUtils.isEmpty(params.get("xydate"))){
                    WHERE("drp.xydate >= '"+params.get("xydate")+"'");
                }
                if(!StringUtils.isEmpty(params.get("approveStatus"))){
                    WHERE("drp.approve_status = '"+params.get("approveStatus")+"'");
                }
            }
        }.toString();
    }
}
